package com.itheima.exception;



import com.itheima.entry.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

//@RestControllerAdvice
public class GlobalExceptionInvoker {
    @ExceptionHandler
    public Result handleException(Exception exception){
        exception.printStackTrace();
        String message=null;
        if (exception.getMessage().length()>200){
            message=exception.getMessage().substring(200);
        }else {
            message=exception.getMessage();
        }

        return new Result(false,message);
    }
}
